package com.oncecloud.devops.service.sample.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.oncecloud.devops.service.sample.dao.UserMapper;
import com.oncecloud.devops.service.sample.entity.User;
import com.oncecloud.devops.service.sample.service.UserService;
@Component
public class UserServiceImpl implements UserService{
	@Autowired
	private UserMapper userMapper;
	@Override
	public String getUserDetail(Integer userId) {
		User user = userMapper.getUser(userId);
		return JSONObject.toJSONString(user);
	}

	@Override
	public String getUsers(String userName) {
		User user = new User();
		user.setUserName(userName);
		List<User> users = userMapper.getUsers(user);
		return JSONArray.toJSONString(users);
	}

	@Override
	public int insert(User user) {
		return userMapper.insert(user);
	}

	@Override
	public int delete(User user) {
		return userMapper.delete(user);
	}

	@Override
	public int update(User user) {
		return userMapper.update(user);
	}

}
